package com.manor.main.adapter

import android.graphics.Bitmap
import android.graphics.drawable.Drawable
import android.widget.ImageView
import android.widget.TextView
import com.bumptech.glide.Glide
import com.bumptech.glide.request.target.CustomTarget
import com.bumptech.glide.request.transition.Transition
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.manor.common.CommonAppConfig
import com.manor.common.bean.ShortVideoBean
import com.manor.main.R

/**
 *

 *
 * @date  2020/7/11  11:55
 * @version 1.0
 */
class UserVideoListAdapter(layoutResId: Int, data: MutableList<ShortVideoBean>)
    : BaseQuickAdapter<ShortVideoBean, BaseViewHolder>(layoutResId, data) {

    override fun convert(holder: BaseViewHolder, item: ShortVideoBean) {
        //R.layout.item_list_video
        item.run {
            holder.setText(R.id.tvNum,likes)

            holder.getView<TextView>(R.id.tvNum).isSelected = islike == "1" || uid == CommonAppConfig.getInstance().uid


            val imgView = holder.getView<ImageView>(R.id.ivImage)
            Glide.with(imgView)
                    .load(thumb)
                    .centerCrop()
                    .into(imgView)




//            Glide.with(imgView)
//                    .load(thumb)
//                    //.thumbnail(0.3f)
//                    .fitCenter()
//                    .into(imgView)
        }

    }


    private val loadTarget = object : CustomTarget<Bitmap>() {
        override fun onLoadCleared(placeholder: Drawable?) {
        }

        override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) {

        }


    }

//    private val loadTarget = object :SimpleTarget<Bitmap>(Target.SIZE_ORIGINAL,Target.SIZE_ORIGINAL){
//        override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) {
//
//        }
//
//    }


}